// JointGenerator.h: interface for the JointGenerator class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_JOINTGENERATOR_H__BE71F464_06C2_4D98_8E5E_89CCEEE8EE15__INCLUDED_)
#define AFX_JOINTGENERATOR_H__BE71F464_06C2_4D98_8E5E_89CCEEE8EE15__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

class Joint;
class Part;
class JGAInfo;
typedef JGAInfo JointGeneratorArithmeticInfo;

#include "Register.h"
#include "ObjectGenerator.h"
#include "Joininfo.h"
#include "RecordsetPtrWrap.h"
#include "ProjectSubObject.h"

namespace VersionControl
{ 
	class DllExport JointGenerator : public ProjectSubObject  
	{
	public:
		typedef JointGeneratorArithmeticInfo JGAI;
		typedef RegisterTemplate<INT, JGAI*> JointGenerateArithmeticRegister;
		typedef ObjectGenerator<JointGenerateArithmeticRegister> JointGenerateArithmeticGenerator;
		
	public:
		virtual Joint* Generate(){ASSERT(FALSE);return NULL;}
		Joint* Generate(DAWrapper::RecordsetPtrWrap& rs);
		Joint* Create(JointFunction* pFirst, JointFunction* pNext);
		
		JointGenerator();
		JointGenerator(Part* pFirst, Part* pNext);
		virtual ~JointGenerator();
		
		static JointGenerateArithmeticRegister& GetJointGenerateArithmetics();

		Part* Next() const {
			return m_pNext;
		}

		void Next(Part* pNext){
			m_pNext = pNext;
		}

		Part* First() const {
			return m_pFirst;
		}

		void First(Part* pFirst){
			m_pFirst = pFirst;
		}

	protected:
		BOOL RunArithmetic(INT nArithmeticIndex, Joint*& pJoint);
		
	private:
		void GetJointAttachs(Joint* pJoint, DAWrapper::RecordsetPtrWrap& jointrs);

	private:
		JointInfo m_First;
		JointInfo m_Next;
		
		Part* m_pNext;
		Part* m_pFirst;
		static JointGenerateArithmeticGenerator m_ArithmeticGenerator;
	};
}
using namespace VersionControl;
#endif // !defined(AFX_JOINTGENERATOR_H__BE71F464_06C2_4D98_8E5E_89CCEEE8EE15__INCLUDED_)
